﻿<UserControl x:Class="Menafrinet.View.Controls.TransmitPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:view="clr-namespace:Menafrinet.View"
             xmlns:vm="clr-namespace:Menafrinet.ViewModel;assembly=Menafrinet.ViewModel"
             xmlns:locations="clr-namespace:Menafrinet.ViewModel.Locations;assembly=Menafrinet.ViewModel"
             xmlns:p="clr-namespace:Menafrinet.View.Properties"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <DataTemplate DataType="{x:Type locations:District}">
            <WrapPanel>
                <TextBlock Text="{Binding Code}"/>
                <TextBlock Text=" - " />
                <TextBlock Text="{Binding Name}"/>
            </WrapPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type locations:Region}">
            <WrapPanel>
                <TextBlock Text="{Binding Code}"/>
                <TextBlock Text=" - " />
                <TextBlock Text="{Binding Name}"/>
            </WrapPanel>
        </DataTemplate>

    </UserControl.Resources>
    <Grid x:Name="grdHome" VerticalAlignment="Stretch" Height="Auto" Style="{StaticResource GradientGrid}" SizeChanged="grdHome_SizeChanged" >
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <Grid x:Name="grdMain" Margin="8, 0, 8, 0" Grid.Row="1" Grid.Column="3" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=ActualHeight}" >

            <Grid x:Name="grdRecordsLayout">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <StackPanel>
                    <TextBlock Grid.Row="0" Grid.ColumnSpan="4" Style="{StaticResource PageHeaderTextBlockStyle}" Text="{x:Static p:Resources.TabTransmissionHeader}" />
                    <StackPanel Height="20" />

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"></RowDefinition>
                        </Grid.RowDefinitions>

                        <Grid x:Name="grdExport">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            
                            <StackPanel Grid.Row="0" Grid.Column="0" Margin="8, 0, 8, 0">
                                <!-- Type d'exportation -->
                                <Label Content="{x:Static p:Resources.ExportType}" />
                                <ListBox x:Name="listboxExportTypes" Height="72" HorizontalAlignment="Left" Width="180" ItemsSource="{Binding}" SelectedIndex="0" ForceCursor="False">
                                    <ListBoxItem Content="{x:Static p:Resources.ExportTypeMonth}" IsSelected="False" x:Name="lbiMonth" IsEnabled="True" />
                                    <ListBoxItem Content="{x:Static p:Resources.ExportTypeDates}" IsSelected="False" x:Name="lbiDates" />
                                    <ListBoxItem Content="{x:Static p:Resources.ExportTypeAllSinceLast}" IsSelected="False" x:Name="lbiAllSinceLast" />
                                    <ListBoxItem Content="{x:Static p:Resources.ExportTypeAll}" IsSelected="False" x:Name="lbiAll" />
                                </ListBox>
                            </StackPanel>

                            <StackPanel Grid.Row="0" Grid.Column="1" Margin="8, 0, 8, 0">
                                <!-- Date de Debut -->
                                <Label Content="{x:Static p:Resources.ExportStartDate}" />
                                <DatePicker HorizontalAlignment="Left" x:Name="datePicker1" Width="115">
                                    <DatePicker.Style>
                                            <Style>
                                            <Setter Property="DatePicker.IsEnabled" Value="False"/>
                                                <Style.Triggers>
                                                <DataTrigger Binding="{Binding ElementName=lbiDates , Path=IsSelected}" Value="True">
                                                    <Setter  Property="DatePicker.IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                    </DatePicker.Style>
                                </DatePicker>

                                <!-- Date de Fin -->
                                <Label Content="{x:Static p:Resources.ExportEndDate}" />
                                <DatePicker HorizontalAlignment="Left" x:Name="datePicker2" Width="115">
                                    <DatePicker.Style>
                                        <Style>
                                            <Setter Property="DatePicker.IsEnabled" Value="False"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ElementName=lbiDates , Path=IsSelected}" Value="True">
                                                    <Setter  Property="DatePicker.IsEnabled" Value="True"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </DatePicker.Style>
                                </DatePicker>
                            </StackPanel>

                            <StackPanel x:Name="panelLabExportType" Grid.Row="0" Grid.Column="2" Margin="8, 0, 8, 0">
                                <Label Content="{x:Static p:Resources.ExportDestinationType}" />
                                <ComboBox x:Name="cmbDestinationType" ItemsSource="{Binding SiteTypes}" >
                                </ComboBox>

                                <Label Content="{x:Static p:Resources.ExportDestinationSite}" />
                                <ComboBox x:Name="cmbDestination" ItemsSource="{Binding ElementName=cmbDestinationType,Path=SelectedItem.Sites}">
                                    <ComboBox.Style>
                                        <Style TargetType="ComboBox">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ElementName=cmbDestinationType, Path=SelectedIndex}" Value="2">
                                                    <Setter Property="SelectedIndex" Value="-1" />
                                                    <Setter Property="IsEnabled" Value="False" />
                                                </DataTrigger>

                                            </Style.Triggers>
                                        </Style>
                                    </ComboBox.Style>
                                </ComboBox>

                                <!--<ListBox x:Name="listboxExportDestinations" Height="60" HorizontalAlignment="Left" Width="109" ItemsSource="{Binding}" SelectedIndex="0" ForceCursor="False">
                                    <ListBoxItem Content="Month" IsSelected="False" x:Name="lbiMonth" IsEnabled="True" />
                                    <ListBoxItem Content="Dates" IsSelected="False" x:Name="lbiDates" />
                                    <ListBoxItem Content="Export all" IsSelected="False" x:Name="lbiAll" />
                                </ListBox>-->
                            </StackPanel>

                            <StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="8, 8, 8, 8">

                                <!-- créer un paquet de données -->
                                <Button x:Name="btnExport" Style="{StaticResource FlatButtonStyle}" Height="Auto" Content="{x:Static p:Resources.ExportCreateDataPackage}" MaxWidth="330" MinWidth="250" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="18" Width="318" Click="btnExport_Click">
                                </Button>

                                <!--<Button FontSize="18" Margin="446,140,40,0" MaxWidth="250" MinWidth="250" x:Name="ExportCopy_btn" Content="copy data files" VerticalAlignment="Top" Grid.Row="1" Height="32" MouseLeftButtonUp="ExportCopy" Visibility="Hidden" />-->
                                <!--<StackPanel Height="10" />-->
                                <Grid Margin="0, 8, 0, 8">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <TextBlock FontWeight="DemiBold" FontSize="13" Margin="4" Grid.Row="0" Grid.Column="0" Text="{x:Static p:Resources.ExportLastExportDate}"></TextBlock>
                                    <TextBlock FontWeight="DemiBold" FontSize="13" Margin="4" Grid.Row="1" Grid.Column="0" Text="{x:Static p:Resources.ExportLastExportUserID}"></TextBlock>
                                    <TextBlock FontWeight="DemiBold" FontSize="13" Margin="4" Grid.Row="2" Grid.Column="0" Text="{x:Static p:Resources.ExportRecordsExported}"></TextBlock>

                                    <TextBlock FontSize="13" Margin="4" Grid.Row="0" Grid.Column="1" Text="{Binding Source={x:Static p:Settings.Default}, Path=DateLastExport, Mode=OneWay}"></TextBlock>
                                    <TextBlock FontSize="13" Margin="4" Grid.Row="1" Grid.Column="1" Text="{Binding Source={x:Static p:Settings.Default}, Path=UserLastExport, Mode=OneWay}"></TextBlock>
                                    <TextBlock FontSize="13" Margin="4" Grid.Row="2" Grid.Column="1" Text="{Binding Source={x:Static p:Settings.Default}, Path=RecordsLastExport, Mode=OneWay}"></TextBlock>
                                    
                                </Grid>
                                <StackPanel Height="5" />
                                <Button x:Name="btnOpenFolder" Style="{StaticResource FlatButtonStyle}" Height="Auto" Content="{x:Static p:Resources.ExportOpenTransmissionFolder}" MaxWidth="250" MinWidth="200" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="14" Click="btnOpenFolder_Click" />
                                <StackPanel Height="10" />
                                <Button x:Name="btnClean" Style="{StaticResource FlatButtonStyle}" Height="Auto" Content="{x:Static p:Resources.ExportPurgeFiles}" MaxWidth="250" MinWidth="200" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="14" Click="btnClean_Click" />
                                <TextBox Visibility="Collapsed" Grid.Row="2" Height="127" HorizontalAlignment="Left" Name="txtTransmit2" VerticalAlignment="Top" Width="682" Text="" IsEnabled="True" DataContext="{Binding}" FontFamily="Arial" />
                            </StackPanel>

                            <StackPanel Margin="30, 0, 0, 0" Grid.Row="0" Grid.Column="3">
                                <TextBox IsReadOnly="True" Width="200" Height="100" VerticalScrollBarVisibility="Auto">
                                    Instructions will go here.
                                </TextBox>
                            </StackPanel>
                        </Grid>
                    </Grid>

                    <StackPanel Margin="8, 0, 8, 0">
                        <Label Content="{x:Static p:Resources.ExportStatus}" HorizontalAlignment="Left" />
                        <TextBox Grid.Row="1" Height="140" VerticalScrollBarVisibility="Visible" x:Name="txtTransmit1" VerticalAlignment="Top" HorizontalAlignment="Stretch" Text="" IsReadOnly="True" Visibility="Visible" />
                        <StackPanel Height="10" />
                        <ProgressBar x:Name="exportProgressBar" Value="0" Height="32" />
                    </StackPanel>

                </StackPanel>

            </Grid>
        </Grid>
    </Grid>
</UserControl>